package day7;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;

public class TestMap {
    public static void main(String[] args) {
        Map<String,Integer> map=new HashMap<>();
        //不允许key和value为null
        //线程安全(增加了同步锁) 效率比较低
        Map<String,Integer> map1=new Hashtable<>();
        //map.put(null,null); 执行会报错 不能为null
        map.put(null,1);
        map.put("123",2);
        //迭代器遍历
        Iterator<Map.Entry<String,Integer>> it=map.entrySet().iterator();
        while (it.hasNext()){
            Map.Entry<String,Integer> e=it.next();
            String key=e.getKey();
            int value=e.getValue();
            System.out.println(key+"==="+value);
        }
        //System.out.println(map1);
        //System.out.println(map);

    }
}
